<?php
/**
 * Created by PhpStorm.
 * User: DELL-PC
 * Date: 2018/8/23
 * Time: 11:14
 */

namespace J\MVC;


use J\Application;
use J\Exception;
use J\Message;

class CommonModule extends Module
{
    /**
     * Constructor.
     * @param Application $app
     * @param string $name
     * @throws Exception
     */
    public function __construct($app, $name)
    {
        $name = ucfirst($name);

        $this->name = $name;

        $this->dir = DEFAULT_MODULE_DIR . DS . 'Application' . DS . $name;
        if(!is_dir($this->dir))
            throw new Exception(Message::INTENT_MODULE_NOT_FIND, ['module' => $name]);

        $this->namespace = trim(DEFAULT_MODULE_NAMESPACE, '\\') . '\\' . $name;

        parent::__construct($app);
    }
}